<?php

namespace App\V3\V3_1\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ContentTagsModel extends Model
{
    use HasFactory;
    protected $table   = 'content_tags';

    static public function addContentTags($data){

        return ContentTagsModel::insertGetId($data);
    }

    static public function getContentTagsList($condition,$sort_number,$currentPage,$pageSize){
         return  ContentTagsModel::select('id','content_tags','pa_id','sort_number','is_top')->where($condition)
         ->where('sort_number','like','%'.$sort_number.'%')
         ->orderBy('is_top', 'DESC')
        ->orderBy('sort_number', 'ASC')
        ->orderBy('create_time', 'ASC')
        ->paginate($pageSize,['*'], '',$currentPage)
        ->toArray();
    }
    static public function getContentTagsList02($condition){
        return  ContentTagsModel::select('id','content_tags','pa_id','sort_number','is_top')->where($condition)
        ->orderBy('is_top', 'DESC')
        ->orderBy('sort_number', 'ASC')
        ->orderBy('create_time', 'ASC')
        ->get()->toArray();
    }
    static public function updContentTags($condition,$updData){

        return ContentTagsModel::where($condition)->update($updData);
    }

    static public function delContentTags($condition){

        return ContentTagsModel::where($condition)->delete();
    }

    static public function getContentTagsInfo($condition){
        return ContentTagsModel::select('id','content_tags','pa_id','sort_number','is_top','main_id')->where($condition)->first();
    }
}
